package com.ysqcould.allocation.service.impl;

import java.util.List;

import com.ysqcould.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ysqcould.allocation.mapper.NavigationMapper;
import com.ysqcould.allocation.domain.Navigation;
import com.ysqcould.allocation.service.INavigationService;

/**
 * 首页导航栏名称Service业务层处理
 * 
 * @author jcd
 * @date 2022-09-19
 */
@Service
public class NavigationServiceImpl implements INavigationService 
{
    @Autowired
    private NavigationMapper navigationMapper;

    /**
     * 查询首页导航栏名称
     * 
     * @param id 首页导航栏名称主键
     * @return 首页导航栏名称
     */
    @Override
    public Navigation selectNavigationById(Long id)
    {
        return navigationMapper.selectNavigationById(id);
    }

    /**
     * 查询首页导航栏名称列表
     * 
     * @param navigation 首页导航栏名称
     * @return 首页导航栏名称
     */
    @Override
    public List<Navigation> selectNavigationList(Navigation navigation)
    {
        return navigationMapper.selectNavigationList(navigation);
    }

    /**
     * 新增首页导航栏名称
     * 
     * @param navigation 首页导航栏名称
     * @return 结果
     */
    @Override
    public int insertNavigation(Navigation navigation)
    {
        navigation.setCreateTime(DateUtils.getNowDate());
        return navigationMapper.insertNavigation(navigation);
    }

    /**
     * 修改首页导航栏名称
     * 
     * @param navigation 首页导航栏名称
     * @return 结果
     */
    @Override
    public int updateNavigation(Navigation navigation)
    {
        navigation.setUpdateTime(DateUtils.getNowDate());
        return navigationMapper.updateNavigation(navigation);
    }

    /**
     * 批量删除首页导航栏名称
     * 
     * @param ids 需要删除的首页导航栏名称主键
     * @return 结果
     */
    @Override
    public int deleteNavigationByIds(Long[] ids)
    {
        return navigationMapper.deleteNavigationByIds(ids);
    }

    /**
     * 删除首页导航栏名称信息
     * 
     * @param id 首页导航栏名称主键
     * @return 结果
     */
    @Override
    public int deleteNavigationById(Long id)
    {
        return navigationMapper.deleteNavigationById(id);
    }

    /**
     * 修改导航栏状态
     * @param navigation
     * @return
     */
    @Override
    public int updateNavigationStatus(Navigation navigation) {
        final Navigation na = navigationMapper.selectNavigationById(navigation.getId());
        na.setStatus(navigation.getStatus());
        final int i = navigationMapper.updateNavigation(na);
        return i;
    }
}
